<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="管养日期">
        <el-date-picker v-model="daterangeCreateDate" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"
          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
          :default-time="['00:00:00', '23:59:59']"></el-date-picker>
      </el-form-item>
      <el-form-item label="公厕名称" prop="toiletName">
        <el-input v-model="queryParams.toiletName" placeholder="请输入公厕名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['toiletv2:toiletV2:remove']">删除</el-button>
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['toiletv2:toiletV2:export']">导出明细</el-button>

        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExportDaily"
          v-hasPermi="['toiletv2:toiletV2:export']">导出日报</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="toiletV2List" @selection-change="handleSelectionChange" @cell-click="cellClick"
      border>
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" prop="idx" />
      <el-table-column label="日期" align="center" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="项目名称" align="center" prop="projectName" />
      <el-table-column label="社区" align="center" prop="community" />
      <el-table-column label="公厕名称" align="center" prop="toiletName" width="250">
        <template slot-scope="scope">
            <span class="link-type" @click="toMonthly(scope.row.toiletName,parseTime(scope.row.createDate, '{y}-{m}-{d}'))">{{ scope.row.toiletName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="异常数量" align="center" prop="anomalyCount" />
      <el-table-column label="公厕正常开放 " align="center" prop="opened" width="100">
        <template slot-scope="scope">
          <TickCross :value="scope.row.opened" />
        </template>
      </el-table-column>
      <el-table-column label="公共洗手间标识" align="center" prop="logo" width="120">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.logo" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="通风除臭" align="center" prop="ventilate">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.ventilate" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="洗手盆" align="center" prop="handBasin">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.handBasin" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="擦手纸或干手机" align="center" prop="handry" width="120">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.handry" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="洗手液" align="center" prop="handSanitizer">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.handSanitizer" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="水龙头" align="center" prop="waterFaucet">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.waterFaucet" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="面镜" align="center" prop="masks">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.masks" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="地面" align="center" prop="floor">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.floor" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="窗户、墙面" align="center" prop="wallspace" width="100">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.wallspace" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="天花板" align="center" prop="ceiling">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.ceiling" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="照明设施" align="center" prop="lights">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.lights" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="厕内整洁" align="center" prop="innerClean">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.innerClean" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="厕门、厕位隔断" align="center" prop="cubicle" width="120">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.cubicle" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="厕间纸巾" align="center" prop="cubicleTissue">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.cubicleTissue" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="大小便器" align="center" prop="toilet">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.toilet" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="厕间干净" align="center" prop="roomClean">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.roomClean" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="冲水设备" align="center" prop="flushing">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.flushing" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="大便器安全扶手" align="center" prop="grabar" width="120">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.grabar" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="手纸架、挂钩、搁物板" align="center" prop="hardware" width="140">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.hardware" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="儿童洗手盆" align="center" prop="childHandBasin" width="110">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.childHandBasin" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="无障碍设施" align="center" prop="barrierfreeFacilities" width="110">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.barrierfreeFacilities" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="母婴室" align="center" prop="babyCareRoom">
        <template slot-scope="scope">
          <div style="cursor: pointer;">
            <TickCross :value="scope.row.babyCareRoom" />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="记录表图片" align="center" prop="originalImage" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.originalImage" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="公厕正常开放-处理前" align="center" prop="openedBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.openedBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="公厕正常开放-处理后" align="center" prop="openedAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.openedAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="公共洗手间标识-处理前" align="center" prop="logoBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.logoBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="公共洗手间标识-处理后" align="center" prop="logoAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.logoAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="通风除臭-处理前" align="center" prop="ventilateBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.ventilateBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="通风除臭-处理后" align="center" prop="ventilateAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.ventilateAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="洗手盆.台-处理前" align="center" prop="handBasinBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.handBasinBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="洗手盆.台-处理后" align="center" prop="handBasinAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.handBasinAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="擦手纸或干手机-处理前" align="center" prop="handryBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.handryBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="擦手纸或干手机-处理后" align="center" prop="handryAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.handryAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="洗手液-处理前" align="center" prop="handSanitizerBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.handSanitizerBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="洗手液-处理后" align="center" prop="handSanitizerAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.handSanitizerAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="水龙头-处理前" align="center" prop="waterFaucetBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.waterFaucetBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="水龙头-处理后" align="center" prop="waterFaucetAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.waterFaucetAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="面镜-处理前" align="center" prop="masksBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.masksBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="面镜-处理后" align="center" prop="masksAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.masksAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="地面-处理前" align="center" prop="floorBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.floorBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="地面-处理后" align="center" prop="floorAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.floorAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="窗户、墙面-处理前" align="center" prop="wallspaceBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.wallspaceBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="窗户、墙面-处理后" align="center" prop="wallspaceAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.wallspaceAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="天花板-处理前" align="center" prop="ceilingBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.ceilingBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="天花板-处理后" align="center" prop="ceilingAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.ceilingAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="照明设施-处理前" align="center" prop="lightsBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.lightsBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="照明设施-处理后" align="center" prop="lightsAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.lightsAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="厕内整洁-处理前" align="center" prop="innerCleanBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.innerCleanBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="厕内整洁-处理后" align="center" prop="innerCleanAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.innerCleanAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="厕门、厕位隔断-处理前" align="center" prop="cubicleBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.cubicleBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="厕门、厕位隔断-处理后" align="center" prop="cubicleAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.cubicleAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="厕间纸巾-处理前" align="center" prop="cubicleTissueBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.cubicleTissueBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="厕间纸巾-处理后" align="center" prop="cubicleTissueAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.cubicleTissueAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="大小便器-处理前" align="center" prop="toiletBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.toiletBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="大小便器-处理后" align="center" prop="toiletAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.toiletAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="厕间干净-处理前" align="center" prop="roomCleanBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.roomCleanBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="厕间干净-处理后" align="center" prop="roomCleanAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.roomCleanAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="冲水设备-处理前" align="center" prop="flushingBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.flushingBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="冲水设备-处理后" align="center" prop="flushingAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.flushingAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="大便器安全扶手-处理前" align="center" prop="grabarBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.grabarBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="大便器安全扶手-处理后" align="center" prop="grabarAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.grabarAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="手纸架、挂钩、搁物板-处理前" align="center" prop="hardwareBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.hardwareBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="手纸架、挂钩、搁物板-处理后" align="center" prop="hardwareAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.hardwareAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="儿童洗手盆-处理前" align="center" prop="childHandBasinBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.childHandBasinBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="儿童洗手盆-处理后" align="center" prop="childHandBasinAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.childHandBasinAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="无障碍设施-处理前" align="center" prop="barrierfreeFacilitiesBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.barrierfreeFacilitiesBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="无障碍设施-处理后" align="center" prop="barrierfreeFacilitiesAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.barrierfreeFacilitiesAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="母婴室-处理前" align="center" prop="babyCareRoomBefore" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.babyCareRoomBefore" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="母婴室-处理后" align="center" prop="babyCareRoomAfter" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.babyCareRoomAfter" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="保洁员" align="center" prop="cleaner" />
      <el-table-column label="保洁员联系电话" align="center" prop="cleanerPhone" />
      <el-table-column label="负责人" align="center" prop="owner" />
      <el-table-column label="负责人联系电话" align="center" prop="phoneNo" />
      <el-table-column label="清洁频率" align="center" prop="cleanCount" />
      <el-table-column label="创建人" align="center" prop="createBy" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>

    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改V2市政公厕管养对话框 -->
    <el-dialog :title="title" :center="true" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="openBill" width="500px" append-to-body>

      <div>
        <div class="itemCenter">{{ billInfo.toiletName }}</div>
        <div class="item">巡检项：<span style="color:#333;">{{ billInfo.itemText }}</span></div>
        <div class="item">工单编码：<span style="color:#333;">{{ billInfo.flowCode }}</span></div>
        <div class="item">工单状态：<span
            style="border:dashed #FEE7DA 1px;display:inline-block;height:24px;color:#F99D45;font-size:12px;line-height:22px;padding:0px 10px;">{{
              billState[billInfo.status] }}</span></div>
        <div class="item">工单流程：</div>
        <el-row style="margin-bottom:15px;">
          <el-col :span="2">
            <div class="i-bar" v-if="billFlow['3'].show == false"></div>
            <div class="i-bar-1" v-else></div>
            <div class="i-border-0" v-if="billFlow['2'].show == false || billFlow['3'].show == true"></div>
            <div class="i-border" v-else></div>
            <div class="i-bar" v-if="billFlow['2'].show == false || billFlow['3'].show == true">
              <svg-icon icon-class="clock"
                style="margin-top:-0.5px;vertical-align: top;padding:0;margin:0;background-color: #fff;color: #44a96c;" />
            </div>
            <div class="i-bar" v-else>
              <svg-icon icon-class="clock"
                style="margin-top:-0.5px;vertical-align: top;padding:0;margin:0;color:#5E6FED;background-color: #fff;" />
            </div>
            <div class="i-border-0"></div>
            <div class="i-over-0" v-if="billFlow['3'].show == false">
              <i class="el-icon-success" style="margin-top:-0.5px;vertical-align: top;color:#e5e5e5;"></i>
            </div>
            <div class="i-over-1" v-else>
              <i class="el-icon-success" style="margin-top:-0.5px;vertical-align: top;color:#44a96c;"></i>
            </div>
          </el-col>
          <el-col :span="22">
            <div class="item-content">
              <div class="item-title">发现</div>
              <div style="font-weight: 400;">
                <div class="item-user">发现人员:</div>
                <div class="item-user-content">{{ billFlow["1"] ? billFlow["1"].user : "" }}<span
                    v-if="billFlow['1'].user"
                    style="color:#fff;background-color: #F99D45;border-radius:2px;font-size:8px;padding:3px;margin-left:5px;">异常</span>
                </div>
              </div>
              <div class="item-time">{{ billFlow["1"] ? billFlow["1"].time : "" }}</div>
            </div>
            <div class="item-content">
              <div class="item-title">待处理</div>
              <div style="font-weight: 400;">
                <div class="item-user">处理人员:</div>
                <div class="item-user-content">{{ billFlow["2"] ? billFlow["2"].user : "" }}</div>
              </div>
              <div class="item-time">{{ billFlow["2"] ? billFlow["2"].time : "" }}</div>
            </div>
            <div>
              <div class="item-title">完成</div>
              <div style="font-weight: 400;">
                <div class="item-user" style="color:#999;">处理人员:</div>
                <div class="item-user-content">{{ billFlow["3"] ? billFlow["3"].user : "" }}<span
                    v-if="billFlow['3'].user"
                    style="color:#fff;background-color: #44a96c;border-radius:2px;font-size:8px;padding:3px;margin-left:5px;">合格</span>
                </div>
              </div>
              <div class="item-time">{{ billFlow["3"] ? billFlow["3"].time : "" }}</div>
            </div>
          </el-col>
        </el-row>
        <div class="item">图例说明：合格为无色，如果由异常转化为合格则为绿色</div>
        <div class="item">
          <div> 处理前：</div>
          <div style="margin-top:10px;"> <image-preview :src="billInfo.imageBefore" :width="80" :height="80" /></div>
        </div>

        <div class="item">
          <div> 处理后： </div>
          <div style="margin-top:10px;">
            <image-preview :src="billInfo.imageAfter" :width="80" :height="80" />
          </div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listToiletV2, delToiletV2 } from "@/api/v2Toilet/toilet";
import { listBills, listInspectItem } from "@/api/v2Toilet/toiletBill";

import TickCross from "@/views/components/tickCross";

export default {
  name: "ToiletV2",
  dicts: ['inspection_status', 'sys_common_status'],
  components: {
    TickCross
  },
  data() {
    return {
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // V2市政公厕管养表格数据
      toiletV2List: [],
      // 弹出层标题
      title: "",
      // 是否新增
      isAdd: true,
      // 是否显示弹出层
      open: false,
      // 删除状态时间范围
      daterangeCreateDate: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        createDate: undefined,
        community: undefined,
        orderByColumn: "createDate,idx",
        isAsc: "desc,asc"
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      openBill: false,
      billInfo: { id: undefined, status: undefined, flowData: undefined, imageBefore: undefined, imageAfter: undefined },
      billFlow: {
        "1": { "user": "", "time": "", "show": false },
        "2": { "user": "", "time": "", "show": false },
        "3": { "user": "", "time": "", "show": false }
      },
      billState: {
        '1': '待处理',  //'异常'
        '2': '已处理',
        '3': '完成',
        '4': ' ',
        '99': '待处理'
      }
      //{0=待处理,1=提交,2=处理中 ，3=完成}

    };
  },
  created() {
    this.getList();
    this.listItems();

  },
  methods: {
    cellClick(row, column, cell, event) {
      let attr = column.property;
      if (this.inspectItems.indexOf(attr) != -1) {

        this.title = row.community || ""
        let billQuery = { toiletId: row.id, item: attr };
        listBills(billQuery).then(response => {
          this.billInfo = response.data;
          if (this.billInfo.imageBefore) {
            this.openBill = true;
            this.billFlow = JSON.parse(this.billInfo.flowData);
          } else {
            return;
          }
        })
      }

    },
    /** 查询V2市政公厕管养列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangeCreateDate && '' != this.daterangeCreateDate) {
        this.queryParams.params["beginCreateDate"] = this.daterangeCreateDate[0];
        this.queryParams.params["endCreateDate"] = this.daterangeCreateDate[1];
      }
      listToiletV2(this.queryParams).then(response => {
        this.toiletV2List = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    listItems() {
      listInspectItem().then(response => {
        // console.log(response)
        this.inspectItems = response;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        createDate: undefined,
        community: undefined,
        toiletName: undefined,
        toiletCode: undefined,
        abnormalCount: undefined,
        opened: undefined,
        logo: undefined,
        ventilate: undefined,
        handBasin: undefined,
        handry: undefined,
        handSanitizer: undefined,
        waterFaucet: undefined,
        masks: undefined,
        floor: undefined,
        wallspace: undefined,
        ceiling: undefined,
        lights: undefined,
        innerClean: undefined,
        cubicle: undefined,
        cubicleTissue: undefined,
        toilet: undefined,
        roomClean: undefined,
        flushing: undefined,
        grabar: undefined,
        hardware: undefined,
        childHandBasin: undefined,
        barrierfreeFacilities: undefined,
        babyCareRoom: undefined,
        owner: undefined,
        phoneNo: undefined,
        cleanCount: undefined,
        remark: undefined,
        createTime: undefined,
        createBy: undefined,
        updateTime: undefined,
        updateBy: undefined,
        delFlag: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeCreateDate = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },

    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除数据项？').then(() => {
        this.loading = true;
        return delToiletV2(ids);
      }).then(() => {
        this.loading = false;
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      }).finally(() => {
        this.loading = false;
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('toiletv2/toiletV2/export', {
        ...this.queryParams
      }, `公厕管养明细${this.parseTime(new Date(), '{y}{m}{d}')}.xlsx`)
      //`toiletV2_${new Date().getTime()}.xlsx`)
      //`设备列表${this.parseTime(new Date(), '{y}{m}{d}')}.xlsx`)
    },
    handleExportDaily() {
      this.download('toiletv2/toiletV2/exportDaily', {
        ...this.queryParams
      }, `公厕管养日报${this.parseTime(new Date(), '{y}{m}{d}')}.xlsx`)

    },
    toMonthly(titleName,queryDate){
      this.$router.push({
        path: '/toiletv2/monthly',
        query:{
          toiletName:titleName,
          queryDate:queryDate
        },
        meta:{
          title:titleName
        }
      })
    }
  }
};
</script>
<style rel="stylesheet/scss" lang="scss">
.info {
  display: inline-block;
  vertical-align: top;
  margin-left: 10px;
  word-break: break-all;
  width: 200px
}

.handCursor {
  cursor: pointer;
}

.toiletv2-danger {
  background-color: red;
  color: #fff;
}

.toiletv2-success {
  background-color: #418151;
  color: #fff;
}

.toiletv2-default {

  color: #fff;
}

.el-dialog {
  border-radius: 5px;
  padding-left: 32px;
  padding-right: 32px;

  .el-dialog__header {
    padding: 8px;
  }

  .el-dialog__body {
    padding: 0;
  }
}

.item {
  font-weight: bolder;
  font-size: 14px;
  color: #999;
  font-weight: 400;
  margin-bottom: 15px;
}

.itemCenter {
  font-weight: bolder;
  font-size: 18px;
  color: #000;
  margin-bottom: 30px;
}

.divider-line {
  border: 1px dashed #000;
  height: 1px;
  overflow: hidden;
}

.msg-content {
  margin-top: 10px;

  .flow {
    display: inline-block;
    font-weight: bold;
    font-size: 16px;
    margin-top: 5px;
    margin-right: 20px;
    margin-left: 60px;
  }

  .mark {
    box-shadow: 0px 0px 3px 3px rgba(0, 0, 0, .2);
    border: solid 1px rgba(0, 0, 0, .2);
    border-radius: 100%;
    color: #fff;
    font-size: 14px;
    padding: 1px;
    width: 28px;
    height: 28px;
    text-align: center;
    display: inline-block;
    vertical-align: top;
    margin-top: 5px;

    .txt {
      background-color: rgba(0, 0, 0, .2);
      border-radius: 100%;
      width: 24px;
      height: 24px;
      line-height: 24px;
    }
  }

  .info {
    display: inline-block;
    vertical-align: top;
    margin-left: 10px;
    word-break: break-all;
    width: 200px
  }

  .status {
    display: inline-block;
    margin-left: 10px;

    .bar {
      color: #fff;
      border-radius: 5px;
      padding: 5px 20px;
    }
  }
}

.tag {
  border-left: solid 3px rgba(0, 0, 0, .2);
  margin-left: 124px;
  height: 30px;
  position: relative;
}

.tag::after {
  content: '';
  position: absolute;
  width: 0px;
  height: 0px;
  top: 30px;
  bottom: 20px;
  left: -6px;
  border: 5px solid;
  border-color: rgba(0, 0, 0, .4) transparent transparent transparent;
}

.el-table .cell {
  padding: 0;
}

.el-table--medium .el-table__cell {
  padding: 0;
}

.i-bar {
  width: 14px;
  height: 14px;
  border-radius: 14px;
  background-color: #5E6FED;
}

.i-bar-1 {
  width: 12px;
  height: 12px;
  border-radius: 12px;
  maring-left: 2px;
  background-color: #44a96c;
}

.i-border-0 {
  border-left: solid 4px #44a96c;
  height: 120px;
  margin-left: 4.5px;
}

.i-border {
  border-left: solid 4px #5E6FED;
  height: 120px;
  margin-left: 4.5px;
}

.i-over-0 {}

.i-over-1 {
  width: 14px;
  height: 14px;
  border-radius: 14px;
  background-color: #fff;
  text-align: center;
}

.item-content {
  height: 134px;
  overflow: hidden;

  .item-title {
    font-size: 14px;
    color: #333;
    font-weight: 700;
  }
}

.item-user {
  display: inline-block;
  color: #999;
  width: 60px;
  vertical-align: top;
}

.item-user-content {
  display: inline-block;
  color: #333;
  width: calc(100% - 60px);
  vertical-align: top;
}

.item-time {
  font-size: 12px;
  color: #999;
}
</style>
